package com.itheima.controller;

import com.itheima.domain.User;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

/**
 * @author Administrator
 */

@Controller
@RequestMapping("/thy")
public class HelloController {


    @RequestMapping("/hello")
    public String index(Model model, String username) {
        model.addAttribute("name", "二狗子");

        System.out.println("username = " + username);

        //List集合
        List<User> list = new ArrayList<>();

        list.add(new User(1L, "二狗子", 10));
        list.add(new User(2L, "狗蛋", 8));
        list.add(new User(3L, "狗剩", 6));
        model.addAttribute("list", list);

        //数组
        String[] str = new String[]{"张三", "李四", "王五"};
        model.addAttribute("str", str);


        //map集合
        Map<String,Object> map = new HashMap<>();

        map.put("name","李清照");
        map.put("address","江陵");
        model.addAttribute("map",map);



        return "hello";
    }


}
